
$(function () {
        $('#firstDate').datetimepicker({
            //viewMode: 'day',
            format: 'YYYY-MM-DD'
        });
        $('#secondDate').datetimepicker({
            format: 'YYYY-MM-DD',
            useCurrent: false //Important! See issue #1075
        });
        $("#firstDate").on("dp.change", function (e) {
            $('#secondDate').data("DateTimePicker").minDate(e.date);
        });
        $("#secondDate").on("dp.change", function (e) {
            $('#firstDate').data("DateTimePicker").maxDate(e.date);
        });


        $('#syso').bootstrapTable({
            url: '${pageContext.request.contextPath}/../../j/Qcxyw',
            columns: [
                {
                    field: 'date',
                    title: '订单时间'
                },{
                    field: 'staff.name',
                    title: '业务员'
                },{
                    field: 'supplier.name',
                    title: '供货商名称'
                },{
                    field:'order',
                    title:'单号'
                },{
                    field: 'ietype.type',
                    title: '类型'
                }, {
                    field: 'money',
                    title: '金额'
                },{
                    field:'warehouse.name',
                    title:'仓库'
                }],


            contentType:"application/x-www-form-urlencoded",

            queryParamsType:'',
            detailView:true,

            height:500,
            pageList:[5,10,15],
            pageNumber:1,
            pageSize:5,
            pagination:true,
            sidePagination:'server',
            queryParams: maven,

            //当点击详细图标展开详细页面的时候触发。
            onExpandRow: function (index, row, $detail) {
                var table = $detail.html("<table></table>").find("table") ;
                table.bootstrapTable({
                    url: '${pageContext.request.contextPath}/../../Qbb/QqueryByOrder?order1='+row.order+'',
                    columns: [{
                        field: 'number',
                        title: '货品编号'
                    },{
                        field: 'name',
                        title: '货品名称'
                    },{
                        field: 'comptype.name',
                        title: '单位'
                    },{
                        field: 'money',
                        title: '单价'
                    },{
                        field: 'num',
                        title: '数量'
                    },{
                        field: 'specid',
                        title: '规格'
                    },{
                        field: 'colortype.name',
                        title: '颜色'
                    },
                        {
                            field:'xx',
                            title:'总金额',
                            formatter: function (value, row, index) {
                                var jia = row.money * row.num;

                                return jia;
                            }
                        }],



                }) ;
            }
        });
    })

function search(){
        var opt = $("#syso").bootstrapTable('getOptions');
        var firstDate = $("#firstDate").val() ;
        var secondDate = $("#secondDate").val();
        var ss = $('#agent').combogrid('getValue');
        $.post('${pageContext.request.contextPath}/../../j/Qcxyw',{"agent":ss,"pageNumber":1,"pageSize":opt.pageSize,"firstDate":firstDate,"secondDate":secondDate},function(data){
            //重新给table绑定数据
            $("#syso").bootstrapTable("load",data) ;
        }) ;
    }
function maven(params) {
    var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
        'pageSize': params.pageSize,  //页面大小
        'pageNumber': params.pageNumber, //页码
        'firstDate' : $("#firstDate").val() ,
        'secondDate': $("#secondDate").val(),
        'agent' : $('#agent').combogrid('getValue'),
    };
    return temp;
};
